<!DOCTYPE html>
<html lang="zh-cn">
<head>
    <meta charset="UTF-8">
    <title>注册</title>
    <link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/bootstrap@5.3.0/dist/css/bootstrap.min.css">
</head>
<body>
<div class="container mt-5">
    <h2>邮箱注册</h2>
    <form method="post">
        <div class="mb-3">
            <label for="email" class="form-label">邮箱</label>
            <input type="email" class="form-control" id="email" name="email" required value="{{ email or '' }}">
        </div>
        <div class="mb-3">
            <label for="password" class="form-label">密码</label>
            <input type="password" class="form-control" id="password" name="password" required>
        </div>
        {% if email %}
        <div class="mb-3">
            <label for="code" class="form-label">验证码</label>
            <input type="text" class="form-control" id="code" name="code" required>
        </div>
        <button type="submit" class="btn btn-primary">完成注册</button>
        {% else %}
        <button type="submit" class="btn btn-primary">发送验证码</button>
        {% endif %}
        <a href="/login" class="btn btn-link">已有账号？登录</a>
    </form>
    {% with messages = get_flashed_messages() %}
      {% if messages %}
        <div class="alert alert-warning mt-3">{{ messages[0] }}</div>
      {% endif %}
    {% endwith %}
</div>
</body>
</html>
